home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_43887.txt < prev    next >
Text File  |  1991-02-27  |  980b  |  24 lines

  1. -- card: 43887 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. ARRAYS OF OBJECTS
  11.  
  12. It is legal to assign the address of an object of one class to a pointer to an ANCESTRAL class.  Therefore it is common to declare an array of pointers to a base class, each of which is assigned a newly-allocated object of a derived class.  For example:
  13.  
  14.     Person  *person[10];
  15.     person[0] = new(Person);
  16.     person[1] = new(Student);
  17.                    .
  18.                    .
  19.  
  20. If the derived class contains member functions which override those of the base class, then passing the appropriate message to the object will invoke the correct method.  However, if the derived class declares a new member function not contained in the base class, then the compiler must be informed of the class of the object before it will accept this message.
  21.  
  22. -- part contents for background part 7
  23. ----- text -----
  24. 121